﻿using System;
using System.Configuration;
using System.Text;
using System.Web.Configuration;

namespace Sunyi.Project.WebPoint.Common
{
    public static class EnvironmentSetting
    {
        public static bool IsDebugMode = false;
        public static string LoginPageUrl = string.Empty;
        public static Encoding DefaultEncoding = Encoding.UTF8;
        public static string DefaultTimeFormat = "yyyy-MM-dd hh:mm:ss";

        public static string UploadFolderUrl = "/Upload/";
        public static string UploadTempFolderUrl = "/Upload/Temp/";
        public static string ControlImageFolderUrl = "/Image/Control/";

        public static string WebSiteRootPath = Environment.CurrentDirectory;

        public static string ConfigurationFolderPath
        {
            get
            {
                return WebSiteRootPath + "\\Configuration\\";
            }
        }

        public static string UploadFolderPath
        {
            get
            {
                return WebSiteRootPath + "\\Upload\\";
            }
        }

        public static string UploadTempFolderPath
        {
            get
            {
                return UploadFolderPath + "\\Temp\\";
            }
        }

        public static string SecurityTokenServiceBindName = "SecurityTokenService";

        static EnvironmentSetting()
        {
            var compilation = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
            if (compilation != null) IsDebugMode = compilation.Debug;

            var authentication = (AuthenticationSection)ConfigurationManager.GetSection("system.web/authentication");
            if (authentication != null && authentication.Forms != null) LoginPageUrl = authentication.Forms.LoginUrl;
        }
    }
}
